import { nullDisplay } from '../utils'
export default {
  props: {
    value: [Object],
    row: Object,
    options: Object
  },
  render(h) {
    if (this.value === null) {
      return nullDisplay(h, this.options || {})
    } else {
      const { id, username, extras, avatar } = this.value || {}
      const { link, center, size } = this.options

      return h('em-cell', {
        attrs: {
          title: username || '匿名用户',
          label: extras || `UID:${id}`,
          to: link,
          center: center || true,
          type: 'media',
          size: size || 'small'
        },
        scopedSlots: {
          icon: () =>
            h('el-avatar', {
              attrs: {
                src: avatar,
                icon: 'el-icon-user-solid',
                size: size || 'small'
              }
            })
        }
      })
    }
  }
}
